package com.yan.demo.arrydemo;

import java.util.Arrays;
import java.util.Scanner;
/*
    66 ->50
*/
public class ArrayTest6 {
    public static void main(String[] args) {
        // 定义10个元素的数组
        int[] arr = {12, 14, 23, 45, 66, 68, 70, 77, 90, 91};
        // 键盘输入一个整数
        Scanner input = new Scanner(System.in);
        System.out.println("请输入一个值");
        int num = input.nextInt();
        // 定义索引值
        int index = -1;
        // for循环找到要插入的点
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] > num){
                index = i;
                break;
            }
        }
        for (int i = arr.length - 1; i > index; i--) {
            arr[i] = arr[i-1];
        }
        arr[index] = num;
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}
